﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using OpenExpressApp.Editors;
using System.Windows.Data;
using Csla.Wpf;

using System.Windows;

namespace OpenExpressApp.Module.WPF.Editors
{
    /// <summary>
    /// 使用DatePicker的日期编辑器
    /// </summary>
    public class DatePropertyEditor : WPFPropertyEditor
    {
        DatePicker _datePicker;

        public DatePropertyEditor(BusinessObjectPropertyInfo propertyInfo, IObjectView view)
            : base(propertyInfo, view) { }

        protected override FrameworkElement CreateEditingElement()
        {
            this._datePicker = new DatePicker()
            {
                Name = PropertyInfo.Name,
            };
            //绑定TextBox到对象属性
            Binding tbbinging = new Binding(PropertyInfo.Name);
            tbbinging.StringFormat = "d";
            this._datePicker.SetBinding(DatePicker.SelectedDateProperty, tbbinging);

            return this._datePicker;
        }
    }
}